<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

	<ui:composition 
	  xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      template="/view/templates/templateLayout.xhtml">
      
      <ui:define name="conteudo">      	
  	  <link rel="stylesheet" type="text/css" href="./estilos.css"/>
  	  
<h:form id="formEditarContaPagar" prependId="false">  
<h:panelGroup id="groupManterContaPagar">
	<p:panel id="panelEditarContaPagar" header="Editar ContaPagar" style="margin-bottom:20px; ">  
	<f:facet name="header">
		<h:outputText value="Editar ContaPagar" styleClass="outputTextTitulo"/>
	</f:facet>
 	<p:messages id="messagesEditarContaPagar" autoUpdate="true" closable="true" /> 
    	<h:panelGrid id="pgContaPagar" columns="5" style="margin-top:20px; margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Descrição" styleClass="outputLabel"/>    
            <h:outputLabel value="Data Vencimento*" styleClass="outputLabel"/> 
            <h:outputLabel value="Data de Pagamento" styleClass="outputLabel"/>   
            <h:outputLabel value="Status" styleClass="outputLabel"/>       
            <p:inputText value="#{contaPagarBean.contaPagar.idContaPagar}" styleClass="inputId" disabled="true"/>  
            <p:inputText value="#{contaPagarBean.contaPagar.descricao}" styleClass="inputDescricao" disabled="true" /> 
            <p:inputMask mask="99/99/9999" value="#{contaPagarBean.contaPagar.dtVencimento}"  styleClass="inputData" disabled="true">
            	<f:convertDateTime dateStyle="medium"/>
            </p:inputMask>	
            <p:inputMask mask="99/99/9999" value="#{contaPagarBean.contaPagar.dtPagamento}" styleClass="inputData" disabled="#{contaPagarBean.disableInput()}">
            	<f:convertDateTime dateStyle="medium"/>
            	<p:ajax listener="#{contaPagarBean.ajaxGet}"/>
            </p:inputMask>
             <p:inputText value="#{contaPagarBean.contaPagar.status}" styleClass="inputDescricao" disabled="true"/>   			
        </h:panelGrid> 
        <h:panelGrid columns="3" style="margin-right:10%;">  
            <h:outputLabel value="Código" styleClass="outputLabel"/>  
            <h:outputLabel value="Fornecedor*" styleClass="outputLabel"/>     
            <h:outputLabel  />           
            <p:inputText value="#{contaPagarBean.contaPagar.fornecedor.idFornecedor}" styleClass="inputId" disabled="true">
            	<f:convertNumber type="number"/>
            </p:inputText>  
  			<p:inputText value="#{contaPagarBean.contaPagar.fornecedor.razaoSocial}" styleClass="inputDescricao" disabled="true"/>  
  			<p:commandButton icon="ui-icon-search" immediate="true" disabled="true"/>
        </h:panelGrid>   
       
       	<h:panelGrid id="pgCondicaoPagamento" columns="6" style="margin-right:10%;" rendered="#{contaPagarBean.renderedCondicaoPagamento()}">  
           	 	<h:outputLabel value="Código" styleClass="outputLabel"/>  
            	<h:outputLabel value="Condição de Pagamento*" styleClass="outputLabel"/>      
            	<h:outputLabel  />       
            	<h:outputLabel value="Código" styleClass="outputLabel"/>  
            	<h:outputLabel value="Forma de Pagamento*" styleClass="outputLabel"/>  
            	<h:outputLabel  />     
            	<p:inputText value="#{contaPagarBean.contaPagar.condicaoPagamento.idCondicaoPagamento}" disabled="true" styleClass="inputId" >
            		<f:convertNumber type="number"/>
            	</p:inputText>	  
  				<p:inputText value="#{contaPagarBean.contaPagar.condicaoPagamento.descricao}"  styleClass="inputDescricao" style="width:150px;"  disabled="true"/>  
  				<p:commandButton icon="ui-icon-search"  disabled="true" />  
            	<p:inputText value="#{contaPagarBean.contaPagar.condicaoPagamento.formaPagamento.idFormaPagamento}" styleClass="inputId" disabled="true"/>  
  				<p:inputText value="#{contaPagarBean.contaPagar.condicaoPagamento.formaPagamento.descricao}"  styleClass="inputDescricao" style="width:150px;" disabled="true"/>   				 
        </h:panelGrid> 
        <h:panelGrid id="pgTotal" columns="6" style="margin-right:10%;">  
        	<h:outputLabel value="Valor(R$)" styleClass="outputLabel"/>	
        	<h:outputLabel value="Juros(%)" styleClass="outputLabel"/>
        	<h:outputLabel value="Multa(R$)" styleClass="outputLabel"/>
        	<h:outputLabel value="Desconto(%)" styleClass="outputLabel"/>
        	<h:outputLabel value="Desconto(R$)" styleClass="outputLabel"/>		
            <h:outputLabel value="Total(R$)" styleClass="outputLabel"/> 
			<p:inputText value="#{contaPagarBean.contaPagar.valor}" styleClass="inputData" maxlength="7" disabled="true">
				<p:ajax  listener="#{contaPagarBean.ajaxGet}" update="inputValorTotal" />
			</p:inputText>    
            <p:inputText id="inputJuros" value="#{contaPagarBean.contaPagar.juros}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableJuros()}">
            	<p:ajax  listener="#{contaPagarBean.calculaJuros}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeJuros}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText>
            <p:inputText value="#{contaPagarBean.contaPagar.multa}" styleClass="inputData" maxlength="7" disabled="#{contaPagarBean.disableInput()}">           	
            	<p:ajax  listener="#{contaPagarBean.calculaMulta}" update="inputValorTotal" />
           	</p:inputText> 
            <p:inputText id="inputDesconto" value="#{contaPagarBean.contaPagar.desconto}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableDesconto()}">           	
            	<p:ajax  listener="#{contaPagarBean.calculaDesconto}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeDesconto}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText> 
            <p:inputText id="inputDescontoReal" value="#{contaPagarBean.contaPagar.descontoReal}" styleClass="inputData" maxlength="5" disabled="#{contaPagarBean.disableDescontoReal()}">           	
            	<p:ajax  listener="#{contaPagarBean.calculaDescontoReal}" update="inputValorTotal" />
            	<p:ajax listener="#{contaPagarBean.onChangeDescontoReal}" update="inputDescontoReal, inputDesconto, inputJuros, inputValorTotal"/>
           	</p:inputText>          
            <p:inputText id="inputValorTotal" value="#{contaPagarBean.contaPagar.valorTotal}" styleClass="inputData" disabled="true" />	
            
        </h:panelGrid>  	
    </p:panel>  
    <p:commandButton id="btSalvar" value="Efetuar Pagamento" onclick="confirmationPagamento.show()" type="button" styleClass="commandButton" rendered="#{contaPagarBean.rendered()}" disabled="#{contaPagarBean.disableInput()}"/> 
	<p:commandButton id="btCancelar" value="Cancelar Conta" onclick="confirmation.show()" type="button" styleClass="commandButton" rendered="#{contaPagarBean.rendered()}" disabled="#{contaPagarBean.disableInput()}"/>
	<p:commandButton value="Voltar" action="#{contaPagarBean.consultarContaPagar}" immediate="true" styleClass="commandButton" /> 
	</h:panelGroup> 
</h:form> 	

    <p:confirmDialog id="confirmDialog" message="Deseja cancelar a conta?"  
                header="Confirmar exclusão" widgetVar="confirmation" appendTo="@(body)" >  
                  
        <p:commandButton id="confirm" value="Sim" oncomplete="confirmation.hide()" process="@this" 
                    action="#{contaPagarBean.cancelarConta}" />  
        <p:commandButton id="decline" value="Não" onclick="confirmation.hide()" type="button" />   
                  
    </p:confirmDialog>
    
    <p:confirmDialog id="confirmDialogPagamento" message="Deseja efetuar o pagamento?"  
                header="Confirmar Pagamento" widgetVar="confirmationPagamento" appendTo="@(body)" >  
                  
        <p:commandButton id="confirmPagamento" value="Sim" oncomplete="confirmationPagamento.hide()" process="@this" 
                    action="#{contaPagarBean.saveContaPagar}" />  
        <p:commandButton value="Não" onclick="confirmationPagamento.hide()" type="button" />   
                  
    </p:confirmDialog>
</ui:define>
</ui:composition>
